#ifndef CONTEXTFREEGRAMMAR_LR1_H
#define CONTEXTFREEGRAMMAR_LR1_H

#include "ContextFreeGrammar.h"
#include <vector>
#include <memory>


class ContextFreeGrammar_LR1 : public ContextFreeGrammar
{
public:
    ContextFreeGrammar_LR1(std::istream & in);
    virtual ~ContextFreeGrammar_LR1();

    void Augment();
    void AssignFirstFollow(const FirstFollowGenerator *);
    void GenerateCollection();
    void Test();

protected:

private:

    void PrintClosure(const Closure &, std::ostream & out = std::cerr) const;
    void PrintClosureList(const ClosureList & cl, std::ostream & out = std::cerr) const;
    void PrintCollection(std::ostream & out = std::cerr) const;

    ClosureList GenerateClosure(const ClosureList & closurelist);
    ClosureList GenerateGoto(const ClosureList & closurelist, StringSet::const_iterator x);

    static bool MergeListKeepUnique(ClosureList& to, const ClosureList& from);

    const FirstFollowGenerator * ffg;

    Collection collection;
    std::map <Collection::const_iterator, std::map<std::string, Collection::const_iterator>> GotoMap;

};

#endif // CONTEXTFREEGRAMMAR_LR1_H
